<?php

/* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */

/* @var $model \common\models\LoginForm */

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\captcha\Captcha;

$this->title = Yii::t('common', 'login');
$this->params['breadcrumbs'][] = $this->title;

?>
<style>


    .lock-wrapper img {
        position: absolute;
        left: 82%;
        top: 49%;
        border-radius: 50%;
        -webkit-border-radius: 9px;
        border: 5px solid #fff;
        display: none;
    }
</style>

<?php $form = ActiveForm::begin([
    'id' => 'login-form',
    'options' => [
        'class' => 'form-signin lock-box text-center'
    ]
]); ?>

<a class="logo floatless" href="/">牧<span>心</span>管理系统</a>
<div class="login-wrap">

    <?= $form->field($model, 'username', [
        'inputOptions' => ['class' => 'form-control', 'placeholder' => Yii::t('common', 'username')],
        'inputTemplate' => '<div class="input-group m-bot15">
                                <span class="input-group-addon"><i class="fa fa-user"></i></span>
                                {input}
                            </div>',

    ])->label(false) ?>
    <?= $form->field($model, 'password', [
        'inputOptions' => ['class' => 'form-control', 'placeholder' => Yii::t('common', 'password')],
        'inputTemplate' => '<div class="input-group m-bot15">
                                <span class="input-group-addon"><i class="fa fa-lock"></i></span>
                                {input}
                            </div>',
    ])->passwordInput()->label(false) ?>

    <?= $form->field($model, 'verifyCode', [
        'inputOptions' => ['class' => 'form-control', 'placeholder' => '输入验证码'],
        'inputTemplate' => '<div class="input-group m-bot15">
                                    <span class="input-group-addon codeinput"><i class="fa fa-lock"></i></span>
                                    {input}
                                </div>',
    ])->label(false); ?>

    <?=
        Captcha::widget(['name' => 'verifyCode', 'captchaAction' => '/site/captcha', 'imageOptions' => ['id' => 'captchaimg', 'title' => '换一个', 'alt' => '换一个', 'style' => 'cursor:pointer;margin-left:25px;'], 'template' => '{image}']);
    ?>

    <?= $form->field($model, 'rememberMe', [
        'inputTemplate' => '{input}',
        'options' => [
        ],
    ])->checkbox() ?>
</div>
    <?= Html::submitButton(Yii::t('common', 'login'), ['class' => 'btn btn-lg btn-login btn-block', 'name' => 'login-button']) ?>

<?php ActiveForm::end(); ?>

<script>
    <?php $this->beginBlock('js') ?>

        $('#loginform-verifycode').focus(function(){
            $('#captchaimg').css('display','block');
        })

    <?php $this->endBlock('js') ?>
    <?php $this->registerJs($this->blocks['js'],\yii\web\View::POS_END); ?>
</script>

